
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/spiermar/d3-flame-graph@2.0.3/dist/d3-flamegraph.css">

    <style>
      body {
        padding-top: 20px;
        padding-bottom: 20px;
      }

      .header {
        padding-bottom: 20px;
        padding-right: 15px;
        padding-left: 15px;
        border-bottom: 1px solid #e5e5e5;
      }

      .header .logo {
        text-decoration: none;
      }

      .header h3 {
        margin-top: 0;
        margin-bottom: 0;
        line-height: 40px;
      }

      .container {
        max-width: 990px;
      }

      table {
        font-family: monospace;
      }

      .table tbody tr th {
        padding: 4px 8px;
        width: 250px;
      }

      .table tbody tr td {
        padding: 4px 8px;
      }

      span {
        font-weight: 700;
        font-family: monospace;
      }
    </style>

    <title>pg_flame</title>

    
    
  </head>
  <body>
    <div class="container">
      <div class="header clearfix">
        <nav>
          <div class="pull-right">
            <form class="form-inline" id="form">
              <a class="btn" href="javascript: resetZoom();">Reset zoom</a>
              <a class="btn" href="javascript: clear();">Clear</a>
              <div class="form-group">
                <input type="text" class="form-control" id="term">
              </div>
              <a class="btn btn-primary" href="javascript: search();">Search</a>
            </form>
          </div>
        </nav>
        <a class="logo" href="https://github.com/mgartner/pg_flame">
          <h3 class="text-muted">pg_flame</h3>
        </a>
      </div>
      <div id="chart">
      </div>
      <hr>
      <div id="details">
      </div>
    </div>

    <script src="https://d3js.org/d3.v4.min.js" charset="utf-8"></script>
    <script type="text/javascript" src=https://cdnjs.cloudflare.com/ajax/libs/d3-tip/0.9.1/d3-tip.min.js></script>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/gh/spiermar/d3-flame-graph@2.1.3/dist/d3-flamegraph.min.js"></script>

    <script type="text/javascript">
    var flameGraph = d3.flamegraph()
      .width(960)
      .cellHeight(18)
      .transitionDuration(750)
      .minFrameSize(5)
      .transitionEase(d3.easeCubic)
      .sort(false)
      .title("")
      .differential(false)
      .selfValue(false)
      .setColorMapper(function(d, originalColor) {
        return d.data.color || originalColor;
      });

    var tip = d3.tip()
      .direction("s")
      .offset([8, 0])
      .attr('class', 'd3-flame-graph-tip')
      .html(function(d) {
        return d.data.name + " | " + d.data.time + " ms";
      });
    flameGraph.tooltip(tip);

    var details = document.getElementById("details");
    flameGraph.setDetailsElement(details);

    var label = function(d) {
      return d.data.detail;
    }
    flameGraph.label(label);

    var data = {"name":"Total","value":50.29,"time":50.29,"detail":"\u003cspan\u003eIncludes planning and execution time\u003c/span\u003e","color":"","init_plan":false,"children":[{"name":"Query Planning","value":1.641,"time":1.641,"detail":"\u003cspan\u003eTime to generate the query plan\u003c/span\u003e","color":"#00C05A","init_plan":false,"children":null},{"name":"Sort","value":48.649,"time":48.649,"detail":"\n\u003ctable class=\"table table-striped table-bordered\"\u003e\n  \u003ctbody\u003e\n    \n      \u003ctr\u003e\n        \u003cth\u003eMethod\u003c/th\u003e\n        \u003ctd\u003eSort\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Cost\u003c/th\u003e\n        \u003ctd\u003e2869.01\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Rows\u003c/th\u003e\n        \u003ctd\u003e1657\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Width\u003c/th\u003e\n        \u003ctd\u003e33\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Total Time\u003c/th\u003e\n        \u003ctd\u003e48.649 ms\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Rows\u003c/th\u003e\n        \u003ctd\u003e106\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Loops\u003c/th\u003e\n        \u003ctd\u003e1\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n    \n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eBuffers Shared Hit\u003c/th\u003e\n        \u003ctd\u003e821\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eSort Key\u003c/th\u003e\n        \u003ctd\u003e[u.id u.email DESC]\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eSort Method\u003c/th\u003e\n        \u003ctd\u003equicksort\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eSort Space Used\u003c/th\u003e\n        \u003ctd\u003e33 kB\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eSort Space Type\u003c/th\u003e\n        \u003ctd\u003eMemory\u003c/td\u003e\n      \u003c/tr\u003e\n    \n  \u003c/tbody\u003e\n\u003c/table\u003e\n","color":"","init_plan":false,"children":[{"name":"Aggregate","value":48.557,"time":48.557,"detail":"\n\u003ctable class=\"table table-striped table-bordered\"\u003e\n  \u003ctbody\u003e\n    \n      \u003ctr\u003e\n        \u003cth\u003eMethod\u003c/th\u003e\n        \u003ctd\u003eAggregate\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eParent Relationship\u003c/th\u003e\n        \u003ctd\u003eOuter\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Cost\u003c/th\u003e\n        \u003ctd\u003e2776.27\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Rows\u003c/th\u003e\n        \u003ctd\u003e1657\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Width\u003c/th\u003e\n        \u003ctd\u003e33\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Total Time\u003c/th\u003e\n        \u003ctd\u003e48.557 ms\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Rows\u003c/th\u003e\n        \u003ctd\u003e106\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Loops\u003c/th\u003e\n        \u003ctd\u003e1\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eFilter\u003c/th\u003e\n        \u003ctd\u003e(count(*) \u0026gt; 1)\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eBuffers Shared Hit\u003c/th\u003e\n        \u003ctd\u003e815\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n    \n    \n    \n    \n    \n  \u003c/tbody\u003e\n\u003c/table\u003e\n","color":"","init_plan":false,"children":[{"name":"Hash Join","value":46.02,"time":46.02,"detail":"\n\u003ctable class=\"table table-striped table-bordered\"\u003e\n  \u003ctbody\u003e\n    \n      \u003ctr\u003e\n        \u003cth\u003eMethod\u003c/th\u003e\n        \u003ctd\u003eHash Join\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eParent Relationship\u003c/th\u003e\n        \u003ctd\u003eOuter\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Cost\u003c/th\u003e\n        \u003ctd\u003e2676.85\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Rows\u003c/th\u003e\n        \u003ctd\u003e4971\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Width\u003c/th\u003e\n        \u003ctd\u003e25\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Total Time\u003c/th\u003e\n        \u003ctd\u003e46.02 ms\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Rows\u003c/th\u003e\n        \u003ctd\u003e4971\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Loops\u003c/th\u003e\n        \u003ctd\u003e1\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eHash Cond\u003c/th\u003e\n        \u003ctd\u003e(u.id = posts.user_id)\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eBuffers Shared Hit\u003c/th\u003e\n        \u003ctd\u003e815\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n    \n    \n    \n    \n    \n  \u003c/tbody\u003e\n\u003c/table\u003e\n","color":"","init_plan":false,"children":[{"name":"Seq Scan on users","value":12.836,"time":12.836,"detail":"\n\u003ctable class=\"table table-striped table-bordered\"\u003e\n  \u003ctbody\u003e\n    \n      \u003ctr\u003e\n        \u003cth\u003eMethod\u003c/th\u003e\n        \u003ctd\u003eSeq Scan\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eTable\u003c/th\u003e\n        \u003ctd\u003eusers\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eAlias\u003c/th\u003e\n        \u003ctd\u003eu\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eParent Relationship\u003c/th\u003e\n        \u003ctd\u003eOuter\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Cost\u003c/th\u003e\n        \u003ctd\u003e1731\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Rows\u003c/th\u003e\n        \u003ctd\u003e100000\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Width\u003c/th\u003e\n        \u003ctd\u003e25\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Total Time\u003c/th\u003e\n        \u003ctd\u003e12.836 ms\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Rows\u003c/th\u003e\n        \u003ctd\u003e100000\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Loops\u003c/th\u003e\n        \u003ctd\u003e1\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n    \n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eBuffers Shared Hit\u003c/th\u003e\n        \u003ctd\u003e731\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n    \n    \n    \n    \n    \n  \u003c/tbody\u003e\n\u003c/table\u003e\n","color":"","init_plan":false,"children":null},{"name":"Hash","value":17.894,"time":17.894,"detail":"\n\u003ctable class=\"table table-striped table-bordered\"\u003e\n  \u003ctbody\u003e\n    \n      \u003ctr\u003e\n        \u003cth\u003eMethod\u003c/th\u003e\n        \u003ctd\u003eHash\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eParent Relationship\u003c/th\u003e\n        \u003ctd\u003eInner\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Cost\u003c/th\u003e\n        \u003ctd\u003e209\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Rows\u003c/th\u003e\n        \u003ctd\u003e4971\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Width\u003c/th\u003e\n        \u003ctd\u003e4\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Total Time\u003c/th\u003e\n        \u003ctd\u003e17.894 ms\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Rows\u003c/th\u003e\n        \u003ctd\u003e4971\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Loops\u003c/th\u003e\n        \u003ctd\u003e1\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n    \n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eBuffers Shared Hit\u003c/th\u003e\n        \u003ctd\u003e84\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eHash Buckets\u003c/th\u003e\n        \u003ctd\u003e8192\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eHash Batches\u003c/th\u003e\n        \u003ctd\u003e1\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eMemory Usage\u003c/th\u003e\n        \u003ctd\u003e239 kB\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n    \n  \u003c/tbody\u003e\n\u003c/table\u003e\n","color":"","init_plan":false,"children":[{"name":"Seq Scan on posts","value":16.073,"time":16.073,"detail":"\n\u003ctable class=\"table table-striped table-bordered\"\u003e\n  \u003ctbody\u003e\n    \n      \u003ctr\u003e\n        \u003cth\u003eMethod\u003c/th\u003e\n        \u003ctd\u003eSeq Scan\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eTable\u003c/th\u003e\n        \u003ctd\u003eposts\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eAlias\u003c/th\u003e\n        \u003ctd\u003eposts\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eParent Relationship\u003c/th\u003e\n        \u003ctd\u003eOuter\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Cost\u003c/th\u003e\n        \u003ctd\u003e209\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Rows\u003c/th\u003e\n        \u003ctd\u003e4971\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003ePlan Width\u003c/th\u003e\n        \u003ctd\u003e4\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Total Time\u003c/th\u003e\n        \u003ctd\u003e16.073 ms\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Rows\u003c/th\u003e\n        \u003ctd\u003e4971\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eActual Loops\u003c/th\u003e\n        \u003ctd\u003e1\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eFilter\u003c/th\u003e\n        \u003ctd\u003e((title)::text ~ \u0026#39;.*sql.*\u0026#39;::text)\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n    \n    \n      \u003ctr\u003e\n        \u003cth\u003eBuffers Shared Hit\u003c/th\u003e\n        \u003ctd\u003e84\u003c/td\u003e\n      \u003c/tr\u003e\n    \n    \n    \n    \n    \n    \n    \n    \n    \n  \u003c/tbody\u003e\n\u003c/table\u003e\n","color":"","init_plan":false,"children":null}]}]}]}]}]};

    d3.select("#chart")
      .datum(data)
      .call(flameGraph);

    document.getElementById("form").addEventListener("submit", function(event){
      event.preventDefault();
      search();
    });

    function search() {
      var term = document.getElementById("term").value;
      flameGraph.search(term);
    }

    function clear() {
      document.getElementById('term').value = '';
      flameGraph.clear();
    }

    function resetZoom() {
      flameGraph.resetZoom();
    }
    </script>
  </body>
</html>
